package com.joysuch.wwyt.datadump.biz.convertor;

import cn.zlg.common.datadump.annotation.DataDumpField;
import cn.zlg.common.datadump.convertor.FieldValueConvert;
import com.joysuch.wwyt.risk.entity.RiskPointType;
import com.joysuch.wwyt.risk.repository.RiskPointTypeDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author ZhaoQiuWei
 * @Date 2021/10/27 13:38
 */
@Component
public class ExportRiskPointTypeCodeConvertor implements FieldValueConvert<String, String> {

    @Autowired
    private RiskPointTypeDao dao;

    @Override
    public String convert(Object bean, String value, DataDumpField dataField) {
        RiskPointType type = dao.findByCode(value);
        if (type != null) {
            return type.getName();
        }
        return null;
    }
}
